package com.mijie.homi.dao.commom;

import java.util.Date;
import java.util.HashMap;

import org.springframework.stereotype.Repository;

import com.mijie.core.IBatisDao;
import com.mijie.homi.common.domain.Grade;
import com.mijie.homi.common.domain.Upgrade;
import com.mijie.homi.domain.commom.EmailVerify;
import com.mijie.homi.domain.commom.ResetPassword;

@Repository
public class MixDao extends IBatisDao {

	public Upgrade getIphoneUpgrade(){
		return this.selectOne("getIphoneUpgrade");
	}
	
	public Grade getRefGradeByIntegral(int integral){
		return this.selectOne("getRefGradeByIntegral", integral);
	}
	
	
	//=========================email verify ================================
	public void emailVerifyApply(int userId,String email,String code){
		HashMap<String,Object> parameter = new HashMap<String,Object>();
		parameter.put("userId", userId);
		parameter.put("email", email);
		parameter.put("code", code);
		parameter.put("createAt", new Date());
		this.insert("emailVerifyApply", parameter);
	}
	
	public EmailVerify getEmailVerifyApply(String code){
		return this.selectOne("getEmailVerifyApply", code);
	}
	
	public void deleteEmailVerifyApply(String code){
		this.delete("deleteEmailVerifyApply", code);
	}
	
	
	//=========================password rest ================================
	public void resetPasswordApply(int userId,String code){
		HashMap<String,Object> parameter = new HashMap<String,Object>();
		parameter.put("userId", userId);
		parameter.put("code", code);
		parameter.put("createAt", new Date());
		this.insert("resetPasswordApply", parameter);
	}
	
	public ResetPassword getResetPasswordApply(String code){
		return this.selectOne("getResetPasswordApply", code);
	}
	
	public void deleteResetPasswordApply(String code){
		this.delete("deleteResetPasswordApply", code);
	}
}
